ARCH ?= x86

ifneq ($(ARCH),x86)
ifneq ($(SDKTARGETSYSROOT),)
<% if (project === 'c') { %>CC := $(CC)
<% } else { %>CC := $(CXX)
<% } %>else
CC = <%= CC %>
endif
else
<% if (project === 'c') { %>CC = gcc
<% } else { %>CC = g++
<% } %>endif

current_path := $(shell pwd)
#源文件目录SRC_DIR
SRC_DIRS := <%= SRC_DIRS %>
SRC_C_EXTRA :=
HEADERS := 
INCLUDE_DIRS := <%= INCLUDE_DIRS %>
EXTRACTED_DIRS := $(sort $(dir $(HEADERS)))
INCLUDE_DIRS += $(EXTRACTED_DIRS)

LIBRARY_DIRS := <%= LIBRARY_DIRS %>
LIBRARIES := <%= LIBRARIES %>

BUILD_DIR = <%= BUILD_DIR %>

CFLAGS := <%= CFLAGS %>
CFLAGS += $(addprefix -I,$(INCLUDE_DIRS))
CFLAGS += $(addprefix -L,$(LIBRARY_DIRS))
CFLAGS += $(LIBRARIES)

SRC := <%= SRC %>
SRC += $(SRC_C_EXTRA)

OBJ := <%= OBJ %>

TARGET := $(BUILD_DIR)/<%= TARGET %>
all: $(TARGET)

$(TARGET): $(OBJ)
	$(CC) -o $@ $^ $(CFLAGS)
<% if (project === 'c') { %>
%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@
<% } else { %>
%.o: %.cpp
	$(CC) $(CFLAGS) -c $< -o $@
<% } %>
clean:
	rm -rf $(TARGET)
	find . -type f -name "*.o" -exec rm -f {} +
.PHONY: all clean
